//
//  NSMutableArray+Extension.m
//  JKRuntimeMethod_exchange
//
//  Created by 王冲 on 2018/10/10.
//  Copyright © 2018年 JK科技有限公司. All rights reserved.
//

#import "NSMutableArray+Extension.h"
#import <objc/runtime.h>
@implementation NSMutableArray (Extension)

+(void)load{
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        Class cls = NSClassFromString(@"__NSArrayM");
        
        // 类簇：NSString、NSArray、NSDictionary，真实类型是其他类型
        Method method1 = class_getInstanceMethod(cls, @selector(insertObject:atIndex:));
        Method method2 = class_getInstanceMethod(cls,@selector(jk_insertObject:atIndex:));
        method_exchangeImplementations(method1, method2);
        
    });
    
    
}

-(void)jk_insertObject:(id)anObject atIndex:(NSUInteger)index{
    
    if (!anObject) {
        return;
    }
    
    [self jk_insertObject:anObject atIndex:index];
}

@end
